"""
合同的数据结构
"""

from typing import Optional, List, Dict
from pydantic import BaseModel, Field


class Contract(BaseModel):
    """合同的id, 名称，段落，其他相关信息"""

    id: str
    name: str
    paragraphs: List[Dict]
    metadata: Optional[dict] = Field(None)


class ParagraphMetadata(BaseModel):
    """段落元数据"""

    relatedBlocks: str = ""


class ContractParagraph(BaseModel):
    """段落id、段落标题、段落内容、段落元数据"""

    paragraphId: str = ""
    title: str = ""
    paragraphContent: List[dict] = [
        {
            "blockType": "text",  # string类型，取值：text、table
            "content": "",
            "textFont": {
                "fontName": "",  # string,可为空字符串
                "fontSize": 12.0,  # float
                "bold": 0,  # int 类型，取值： 0-不是黑体，1-是黑体
            },
            "blockIndex": 0,  # int 类型，段落中的位置
        }
    ]
    metadata: ParagraphMetadata = ParagraphMetadata()

class ContractInfo(BaseModel):
    docId:str
    docContent:List[ContractParagraph]=ContractParagraph()


if __name__ == "__main__":
    res = ContractInfo(doc_id='').model_dump()
    print(res)
    # import json

    # print(json.dumps(res, default=lambda x: x.__dict__, ensure_ascii=False, indent=4))
